package org.extremengine.shape;

import org.extremengine.common.Point;
import org.extremengine.common.Velocity;

/**
 * 表示物理世界中刚体的形状。
 * @author yuxing
 */
public abstract class Shape {
	
	public static final int COORDINATE_AXIS_X = 1;
	public static final int COORDINATE_AXIS_Y = 2;

	/**
	 * Is this a circle?
	 * @return
	 */
	public boolean isCircle() {
		return this instanceof Circle;
	}
	
	/**
	 * Barycenter is the center of the gravity.
	 * @return
	 */
	public abstract Point getBarycenter();
	
	/**
	 * Transform position by delta X and delta Y.
	 * @param deltax
	 * @param deltay
	 */
	public abstract void transform(double deltax, double deltay);
	
	/**
	 * Transform position by velocity and time.
	 * @param v
	 * @param timePeirod Millisecond
	 */
	public void transform(Velocity v, long timePeirod) {
		double deltax = (v.getSpeedx() * timePeirod) / 1000;
		double deltay = (v.getSpeedy() * timePeirod) / 1000;
		transform(deltax, deltay);
	}
	
	/**
	 * Deep copy.
	 */
	public abstract Shape clone();
	
	public static interface CurveFunction {
		public int f(int x);
	}
	
	public static interface LineFunction extends CurveFunction{
		
	}
}
